import axios from "axios";

const instance = axios.create({
    baseURL: "/",   // 使用 mockjs 需要将 baseURL 书写为 /
    timeout: 60000,
});

export function ajax(options) {
    const { url, method = "get", data = {} } = options;

    if (method.toUpperCase() === "GET") {
        return instance.get(url, { params: data });
    } else {
        return instance.post(url, data);
    }
}
